package com.school.hjt.schoolclasscard.db;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Unique;

/**
 * Created by xqx on 2017/11/16.
 * 卡号
 */
@Entity
public class Cardnumber {
    @Id
    private String id;//卡号id
    @Unique
    private String cardnumber;//卡号
    private int type;//卡号类型
    @ToOne(joinProperty = "id")
    private CardStudent cardStudent;//关联学生
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 61826828)
    private transient CardnumberDao myDao;
    @Generated(hash = 1857348624)
    private transient String cardStudent__resolvedKey;
    @Generated(hash = 368288435)
    public Cardnumber(String id, String cardnumber, int type) {
        this.id = id;
        this.cardnumber = cardnumber;
        this.type = type;
    }
    @Generated(hash = 814580316)
    public Cardnumber() {
    }
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getCardnumber() {
        return this.cardnumber;
    }
    public void setCardnumber(String cardnumber) {
        this.cardnumber = cardnumber;
    }
    public int getType() {
        return this.type;
    }
    public void setType(int type) {
        this.type = type;
    }
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1757342300)
    public CardStudent getCardStudent() {
        String __key = this.id;
        if (cardStudent__resolvedKey == null || cardStudent__resolvedKey != __key) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            CardStudentDao targetDao = daoSession.getCardStudentDao();
            CardStudent cardStudentNew = targetDao.load(__key);
            synchronized (this) {
                cardStudent = cardStudentNew;
                cardStudent__resolvedKey = __key;
            }
        }
        return cardStudent;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 799538978)
    public void setCardStudent(CardStudent cardStudent) {
        synchronized (this) {
            this.cardStudent = cardStudent;
            id = cardStudent == null ? null : cardStudent.getId();
            cardStudent__resolvedKey = id;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1043017292)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getCardnumberDao() : null;
    }

}
